package com.project.service.impl;

import com.project.bean.BuyCarBean;
import com.project.bean.BuyInfoBean;
import com.project.mapper.IBuyInfoMapper;
import com.project.mapper.IBuyMapper;
import com.project.service.IBuyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BuyInfoServiceImpl implements IBuyInfoService {
    @Autowired
    private IBuyInfoMapper  buyInfoMapper;
    @Override
    public void addMore(Integer buyId, List<BuyCarBean> buyCarList) {
        for (BuyCarBean buyCarBean:buyCarList){
            BuyInfoBean buyInfoBean = new BuyInfoBean(buyCarBean.getPrice(),
                    buyCarBean.getNum(), buyCarBean.getGoodsId(),buyId);
            buyInfoMapper.insert(buyInfoBean);
        }
    }

    @Override
    public void add(BuyInfoBean buyInfoBean) {
        buyInfoMapper.insert(buyInfoBean);
    }
}
